package com.bank.backend.enums;

/**
 * 存款类型枚举
 */
public enum DepositTypeEnum {

    DEMAND("活期", "活期存款，随时存取", null),
    FLEXIBLE("定活两便", "定活两便存款", null),
    FIXED_1Y("整存整取1年", "整存整取1年期", 1),
    FIXED_2Y("整存整取2年", "整存整取2年期", 2),
    FIXED_3Y("整存整取3年", "整存整取3年期", 3),
    ZERO_WHOLE("零存整取", "零存整取存款", null);

    private final String value;
    private final String description;
    private final Integer termYears;

    /**
     * 构造器
     */
    DepositTypeEnum(String value, String description, Integer termYears) {
        this.value = value;
        this.description = description;
        this.termYears = termYears;
    }

    /**
     * 获取值
     */
    public String getValue() {
        return value;
    }

    /**
     * 获取描述
     */
    public String getDescription() {
        return description;
    }

    /**
     * 获取存期
     */
    public Integer getTermYears() {
        return termYears;
    }
    
    /**
     * 根据值获取枚举
     */
    public static DepositTypeEnum getByValue(String value) {
        for (DepositTypeEnum type : values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return null;
    }
    }